package com.yfp.goods.enums;

import com.yfp.common.core.exception.ServiceException;

/**
 * 口味枚举
 *
 *
 * @date 2023/12/26
 */
public enum TasteEnum {

    NOT_SPICY("不辣", 1),
    SLIGHTLY_SPICY("微辣", 2),
    MEDIUM_SPICY("中辣", 3),
    HEMP_SPICY("麻辣", 4);

    private String name;
    private Integer value;

    TasteEnum(String name, Integer value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public Integer getValue() {
        return value;
    }

    /**
     * 通过val获取辣度枚举名称
     *
     * @param value 价值
     * @return {@link String}
     */
    public static String getTasteEnumNameByVal(Integer value) {
        for (TasteEnum tasteEnum : TasteEnum.values()) {
            if (tasteEnum.getValue().equals(value)) {
                return tasteEnum.name;
            }
        }
        throw new ServiceException("未找到对应类型");
    }
}
